package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class ConfigActivity extends AppCompatActivity {
    private static final String TAG = "config";
    private EditText dollarText;
    private EditText euroText;
    private EditText wonText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);
        Log.i(TAG, "onCreate:...");
        Intent intent = getIntent();
        float dollar = intent.getFloatExtra("dollar_key", 630.49f);
        float euro = intent.getFloatExtra("euro_key", 672.14f);
        float won = intent.getFloatExtra("won_key", 0.4999f);

        Log.i(TAG, "onCreate:dollar=" + dollar);
        Log.i(TAG, "onCreate:euro=" + euro);
        Log.i(TAG, "onCreate:won=" + won);

        dollarText = findViewById(R.id.new_dollar);
        euroText = findViewById(R.id.new_euro);
        wonText = findViewById(R.id.new_won);

        dollarText.setText(String.valueOf(dollar));
        euroText.setText(String.valueOf(euro));
        wonText.setText(String.valueOf(won));
    }
     public void save(View btn){
        Log.i(TAG,"save: ");

        String dollarStr = dollarText.getText().toString();
        String euroStr = euroText.getText().toString();
        String wonStr = wonText.getText().toString();

        Intent intent = getIntent();

        Bundle bundle = new Bundle();
        bundle.putFloat("key_dollar2",Float.parseFloat(dollarStr));
         bundle.putFloat("key_euro2",Float.parseFloat(euroStr));
         bundle.putFloat("key_won2",Float.parseFloat(wonStr));
         intent.putExtras(bundle);

         setResult(6,intent);
         finish();


     }



}